package routers

import (
	"github.com/gin-contrib/sessions"
	"github.com/gin-contrib/sessions/cookie"
	"gvb_server/api"
	"gvb_server/middleware"
)

var store = cookie.NewStore([]byte("HyvCD89g3VDJ9646BFGEh37GFJ"))

func (routerGroup RouterGroup) UsersRouter() {
	usersApi := api.ApiGroupApp.UserApi
	routerGroup.Use(sessions.Sessions("sessionid", store))
	routerGroup.POST("email_login", usersApi.EmailLoginView)
	routerGroup.GET("/users", middleware.JwtAuth(), usersApi.UserListView)
	routerGroup.POST("/user_role", middleware.JwtAdmin(), usersApi.UserUpdateRoleView)
	routerGroup.POST("/user_password", middleware.JwtAuth(), usersApi.UserUpdatePassword)
	routerGroup.POST("/user_logout", middleware.JwtAuth(), usersApi.LogoutView)
	routerGroup.POST("/user_bind_email", middleware.JwtAuth(), usersApi.UserBindEmailView)
	routerGroup.POST("/users", middleware.JwtAuth(), usersApi.UserCreateView)
}
